package com.hfzy.ihk.facade.freeswitchManage.enums;

import com.hfzy.ihk.common.facade.CustomEnumType;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * 公司枚举
 */
public enum CompanyEnum implements CustomEnumType {
    HFZY("HFZY", "合富置业"),
    BL("BL", "保利爱家");

    private CompanyEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String value;

    public String desc;

    public String getDesc() {
        return desc;
    }

    public String toStr() {
        return value;
    }

    /**
     * 用于页面枚举转换
     * @return
     */
    @Override
    public String getValue() {
        return this.value;
    }
    @Override
    public String toString(){
        return this.desc;
    }

    private static Map<String, CompanyEnum> map = new HashMap<String, CompanyEnum>();

    static {
        for (CompanyEnum value : CompanyEnum.values())
            map.put(value.toStr(), value);
    }

    public static CompanyEnum fromStr(String name) {
        CompanyEnum ret = map.get(name);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const "
                    + CompanyEnum.class + "." + name);
    }

    private static Map<String, CompanyEnum> descMap = new HashMap<String, CompanyEnum>();

    static {
        for (CompanyEnum value : CompanyEnum.values())
            descMap.put(value.getDesc(), value);
    }

    public static CompanyEnum fromDesc(String desc) {
        CompanyEnum ret = descMap.get(desc);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const " + CompanyEnum.class
                    + "." + desc);
    }

    private static Map<String, String> keyMap = new HashMap<String, String>();

    static {
        for (CompanyEnum value : CompanyEnum.values())
            keyMap.put(value.toStr(), value.getDesc());
    }

    public static String fromKey(String key) {
        String ret = keyMap.get(key);
        if (ret != null)
            return ret;
        else
            throw new IllegalArgumentException("No enum const " + CompanyEnum.class
                    + "." + key);
    }

    public static boolean isDefined(String value){
        if(map.containsKey(value)) {
            return true;
        }else{
            return false;
        }
    }
}
